From 38321eacbf0d99e232f91dc5d908cb36e024578b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 7 Dec 2010 12:59:17 -0500 Subject: [PATCH] GtkStyleContext migration guide tweaks Move the guide into the 2-to-3 guide, since it is something you have to do when porting from 2 to 3. Also add an example for handling of temporary state changes and some more text about color handling. --- docs/reference/gtk/migrating-2to3.xml | 3 + .../gtk/migrating-GtkStyleContext.xml | 82 +++++++++++++------ 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/docs/reference/gtk/migrating-2to3.xml b/docs/reference/gtk/migrating-2to3.xml index fc39ff1e24..ad0919b9a8 100644 --- a/docs/reference/gtk/migrating-2to3.xml +++ b/docs/reference/gtk/migrating-2to3.xml @@ -1,6 +1,7 @@ ]> Migrating from GTK+ 2.x to GTK+ 3 @@ -954,6 +955,8 @@ gtk_arrow_draw (GtkWidget *widget, + + diff --git a/docs/reference/gtk/migrating-GtkStyleContext.xml b/docs/reference/gtk/migrating-GtkStyleContext.xml index 775fee0545..ef87ab5afc 100644 --- a/docs/reference/gtk/migrating-GtkStyleContext.xml +++ b/docs/reference/gtk/migrating-GtkStyleContext.xml @@ -1,9 +1,9 @@ - - - Migrating from GtkStyle to GtkStyleContext +
+ Theming changes In GTK+ 3.0, #GtkStyleContext was added to replace #GtkStyle and @@ -14,7 +14,7 @@ porting applications, libraries and widgets. - +
Migrating themes @@ -27,9 +27,9 @@ with possible variants such as the dark theme being named gtk-dark.css in the same directory. - +
- +
Migrating theme engines @@ -141,9 +141,9 @@ attempt to handle. - +
- +
Extending the CSS parser @@ -175,9 +175,9 @@ style property can be modified in CSS as -GtkWidget-focus-line-width. - +
- +
Using the CSS file format @@ -358,6 +358,15 @@ independently. + + In the same vein, the light, dark and mid color variants that + were available in GtkStyle should be replaced by a combination of + symbolic colors and custom CSS, where necessary. text_aa should + really not be used anywhere, anyway, and the white and black colors + that were available in GtkStyle can just be replaced by literal + GdkRGBA structs. + + Access to colors has also changed a bit. With #GtkStyle, the common way to access colors is: @@ -393,9 +402,9 @@ It is worth mentioning that the new file format does not support custom keybindings nor stock icon mappings as the RC format did. - +
- +
A checklist for widgets @@ -486,15 +495,34 @@ - Replace all gtk_paint_*() calls with corresponding - gtk_render_*() calls. The most distinctive changes - are the use of #GtkStateFlags to represent the widget state and the - lack of #GtkShadowType. For gtk_render_check() and gtk_render_option(), - the @shadow_type parameter is replaced by the #GTK_STATE_FLAG_ACTIVE - and #GTK_STATE_FLAG_INCONSISTENT state flags. For things such as - pressed/unpressed button states, #GTK_STATE_FLAG_ACTIVE is used, and - the CSS may style normal/active states differently to render - outset/inset borders, respectively. + + Replace all gtk_paint_*() calls with corresponding + gtk_render_*() calls. + + + The most distinctive changes are the use of #GtkStateFlags to + represent the widget state and the lack of #GtkShadowType. Note + that widget state is now passed implicitly via the context, so + to render in a certain state, you have to temporarily set the + state on the context, as in the following example: + + + Rendering with a specific state + + gtk_style_context_save (context); + gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE); + gtk_render_check (context, cr, x, y, width, height); + gtk_style_context_restore (context); + + + + For gtk_render_check() and gtk_render_option(), the @shadow_type + parameter is replaced by the #GTK_STATE_FLAG_ACTIVE and + #GTK_STATE_FLAG_INCONSISTENT state flags. For things such as + pressed/unpressed button states, #GTK_STATE_FLAG_ACTIVE is used, + and the CSS may style normal/active states differently to render + outset/inset borders, respectively. + @@ -515,9 +543,9 @@ of this is merely a guideline. Widgets may choose to follow it or not. - +
- +
Parsing of custom resources As a consequence of the RC format going away, calling gtk_rc_parse() or @@ -534,9 +562,9 @@ by implementing the #GtkStyleProvider interface yourself. This is an advanced feature that should be rarely used. - +
- +
Bonus points @@ -627,5 +655,5 @@ - - +
+
-- 2.30.2